﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SISTEMA_ALPROVIDE.Bean;
using SISTEMA_ALPROVIDE.Service;

namespace SISTEMA_ALPROVIDE
{
    public partial class fmAdministrar_ClienteVenta : Form
    {
        private string ventana;
        public Cliente cliente = new Cliente();
        public ServiceCliente serviceCliente = new ServiceCliente();

        public fmAdministrar_ClienteVenta()
        {
            InitializeComponent();
        }

        public fmAdministrar_ClienteVenta(string ventana)
        {
            // TODO: Complete member initialization
            this.ventana = ventana;
            InitializeComponent();
            textBox1.Enabled = false;
            textBox2.Enabled = false;
            textBox3.Enabled = false;
            textBox4.Enabled = false;
            textBox5.Enabled = false;
            textBox6.Enabled = false;
            textBox7.Enabled = false;
            textBox8.Enabled = false;
            textBox9.Enabled = false;
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            
        }

        private void GridVenta_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            string DNI = tbxDNI.Text;
            string ApellidoPaterno = tbxApellidoPaterno.Text;

            List<Cliente> listaCliente = serviceCliente.ObtenerCliente(DNI, ApellidoPaterno);

            GridCliente.DataSource = listaCliente;

            GridCliente.Columns[0].Visible = false;
            GridCliente.Columns[5].Visible = false;
        }

        private void GridCliente_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= -1 && e.Button == MouseButtons.Left)
            {
                //MessageBox.Show(e.RowIndex + " " + e.ColumnIndex);
                cliente.idPersona = Convert.ToInt32(GridCliente.Rows[e.RowIndex].Cells[0].Value);
                cliente.DNI = Convert.ToInt32(GridCliente.Rows[e.RowIndex].Cells[1].Value);
                cliente.Nombre = Convert.ToString(GridCliente.Rows[e.RowIndex].Cells[2].Value);
                cliente.ApellidoPaterno = Convert.ToString(GridCliente.Rows[e.RowIndex].Cells[3].Value);
                cliente.ApellidoMaterno = Convert.ToString(GridCliente.Rows[e.RowIndex].Cells[4].Value);                

            }
        }
    }
}
